using XDQ.VAT.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace XDQ.VAT.Permissions
{
    public class VATPermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            var myGroup = context.AddGroup(VATPermissions.GroupName);

            //Define your own permissions here. Example:
            //myGroup.AddPermission(VATPermissions.MyPermission1, L("Permission:MyPermission1"));


            var appStudentPermission = myGroup.AddPermission(VATPermissions.AppStudent.Default, L("Permission:AppStudent"));
            appStudentPermission.AddChild(VATPermissions.AppStudent.Create, L("Permission:Create"));
            appStudentPermission.AddChild(VATPermissions.AppStudent.Update, L("Permission:Update"));
            appStudentPermission.AddChild(VATPermissions.AppStudent.Delete, L("Permission:Delete"));

            var appClassPermission = myGroup.AddPermission(VATPermissions.AppClass.Default, L("Permission:AppClass"));
            appClassPermission.AddChild(VATPermissions.AppClass.Create, L("Permission:Create"));
            appClassPermission.AddChild(VATPermissions.AppClass.Update, L("Permission:Update"));
            appClassPermission.AddChild(VATPermissions.AppClass.Delete, L("Permission:Delete"));

            var appCoursePermission = myGroup.AddPermission(VATPermissions.AppCourse.Default, L("Permission:AppCourse"));
            appCoursePermission.AddChild(VATPermissions.AppCourse.Create, L("Permission:Create"));
            appCoursePermission.AddChild(VATPermissions.AppCourse.Update, L("Permission:Update"));
            appCoursePermission.AddChild(VATPermissions.AppCourse.Delete, L("Permission:Delete"));

            var appExamPermission = myGroup.AddPermission(VATPermissions.AppExam.Default, L("Permission:AppExam"));
            appExamPermission.AddChild(VATPermissions.AppExam.Create, L("Permission:Create"));
            appExamPermission.AddChild(VATPermissions.AppExam.Update, L("Permission:Update"));
            appExamPermission.AddChild(VATPermissions.AppExam.Delete, L("Permission:Delete"));
        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<VATResource>(name);
        }
    }
}
